<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="<%=basePath %>leyuiyc/css/font.css">
        <link rel="stylesheet" href="<%=basePath %>leyuiyc/css/xadmin.css">
        <script src="<%=basePath %>leyuiyc/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="<%=basePath %>leyuiyc/js/xadmin.js"></script>
		<style>
		    /* body{overflow-y: scroll;} */ /* 禁止刷新后出现横向滚动条 */
		    /* .layui-table-body .layui-table,.layui-table-header .layui-table{width: 100%;}
			.layui-table-body.layui-table-main .layui-table-cell,.layui-table-header .layui-table-cell{white-space: pre-wrap;word-wrap: break-word; word-break: break-all; height: auto;} */
		</style>
        <script src="<%=basePath %>leyuiyc/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="<%=basePath %>leyuiyc/js/xadmin.js"></script>
		
    </head>
    
    <body>
        
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form" id="test" lay-filter="test">
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    <script type="text/html" id="switchTpl">
  <!-- 这里的 checked 的状态只是演示 -->
<div class="layui-input-inline">
      <input type="text" name="titl" id="num" class="layui-input" value="{{d.number }}" >
</div>
</script>
    <script>
			layui.use(['table','form','slider','layedit', 'laydate', "jquery"], function(){
				  var form = layui.form
				  ,layer = layui.layer
				  ,layedit = layui.layedit
				  ,laydate = layui.laydate
				  ,slider = layui.slider
				  ,table = layui.table
				  ,$ = layui.jquery;
		        var purchaseId = ${purchaseId};
			  table.render({
			    elem: '#test'
			    ,url:'selectTvPurchaseDetails.do?purchaseId='+purchaseId
			    ,width: 'auto'
			    ,height: 650
			    ,method: 'post'
			    ,title: '修改采购单详情'
			    ,totalRow: true
			    ,page: false
			    ,cols: [[
			       {field:'purchaseGoodsId', width:100, title: '序号', fixed: 'left',type:'numbers'}
			      ,{field:'purchaseId', width:200, title: '采购单编号id'}
			      ,{field:'specId', width:200, title: '规格',toolbar:'#specId'}
			      ,{field:'goodsName', width:100, title: '商品名称'}
			      ,{field:'specifications', width: 200, title: '商品类型'}
			      ,{field:'number', width:100, title: '采购数量',templet:'#switchTpl', unresize: true}
			      ,{field:'fwpoint', width:260, title: '所属服务点'}
			      ,{field:'', width:180, title: '保存',toolbar:'#operation',align:'center'}
			    ]]
			    ,even:true
			    ,skin: 'row' //表格风格
			  });
			  table.on('tool(test)', function(obj) {
    			var data = obj.data;
    			var purchaseId = data.purchaseId;//采购单编号
    			var number = $("#num").val();
    			
    			if (obj.event === 'update'){
    				$.ajax({
	                    	url:"UpdateTvPurchaseDetails.do",
	                    	type:"post",
	                    	dataType:"json",
	                    	data:{
	                    	"purchaseId":purchaseId
	                    	,"number":number
	                    	},	                    	
	                    	success:function(data){
	                    	console.log(data);
	                    		if(data!=null&&data!='0'){
	                    			layer.msg('修改成功', {
    									icon : 1
    								});
    								return;
	                    		}
	                    		return;
	                    		}
	                    	})
	    			}
    		})
    	});
    	
	</script>
	<script type="text/html" id="specId">	
	   {{#  if(d.specId == "0") {  }}
			<font color="#00ff00">正品</font>
		{{#  } else if(d.specId == "5") {  }}
			<font color="#00FA9A">打包商品</font>
         {{#  } else if(d.specId == "6") {  }}
			<font color="#00EE00">其它商品</font>
		{{#  } else {  }}
			<div><font color="#0000FF">新商品</font></div>
		{{#  }  }}
    </script>
    <script type="text/html" id="operation">
               <a lay-event="update"><button class="layui-btn" >保存修改</button></a>
 	</script>
</html>